how do i make sure a line doesnt repeat from a file in python

35

from random import sample

file_name = "text_database.txt"
lines = open(file_name, "r").read().splitlines()

for line in sample(lines, k=len(lines)):
    print(line)

Comments

Submit
0 Comments